package model

import BaseConfig
import business.Attackable
import business.Blockable
import business.Destroyable
import business.Sufferable
import org.itheima.kotlin.game.core.Composer
import org.itheima.kotlin.game.core.Painter

class Wall(override val x: Int, override val y: Int) : Blockable, Sufferable, Destroyable {


    override var blood: Int = 3
    override val width: Int = BaseConfig.GAME_UNIT
    override val height: Int = BaseConfig.GAME_UNIT

    override fun draw() {
        Painter.drawImage("img/wall.gif", x, y)
    }

    override fun isDestroy(): Boolean {
        return blood < 0
    }

    override fun notifySuffer(attackable: Attackable): Array<IView>? {
//        println("墙被攻击了。。。")
        blood -= attackable.attackBlood
        // 播放击中的声音
        Composer.play("snd/hit.wav")
        return arrayOf(Blast(x, y))
    }

}